from django.conf import settings
try:
    # Django 2.0+
    from django.urls import include, re_path
except ImportError:
    # Django 1.x
    from django.urls import include, url as re_path

from django.views.generic import TemplateView
from django.contrib import admin

# 启用Django admin并设置站点信息
admin.autodiscover()
admin.site.site_header = "MES 制造执行系统"
admin.site.site_title = "MES Admin"
admin.site.index_title = "欢迎使用 MES 管理系统"

urlpatterns = [
    # Django原生管理后台
    re_path(r'^admin/', admin.site.urls),
    
    # 首页
    re_path(r"^$", TemplateView.as_view(template_name="homepage.html"), name="home"),
    
    # 基础页面
    re_path(r"^about/$", TemplateView.as_view(template_name="about.html"), name="about"),
    re_path(r"^about_us/$", TemplateView.as_view(template_name="direct_pages/about_us.html"), name="about_us"),
    re_path(r"^contacts$", TemplateView.as_view(template_name="direct_pages/about_us.html"), name="contacts"),
    
    # 项目应用的URL（根据需要启用）
    # re_path(r"^companydepartment/", include("companydepartment.urls")),
    # re_path(r"^technology/", include("technologies.urls")),
    # re_path(r"^manufactureplan/", include("manufactureplan.urls")),
    # re_path(r"^quality/", include("quality.urls")),
    # re_path(r"^warehouse/", include("warehouse.urls")),
    # re_path(r"^report/", include("report.urls")),
    # re_path(r"^file/", include("yt_file.urls")),
    
    # 第三方应用URL（根据需要启用）
    # re_path(r"^notices/", include("notification.urls")),
    # re_path(r"^announcements/", include("announcements.urls")),
    # re_path(r'^messages/', include('django_messages.urls')),
]

# 静态文件服务（仅在开发模式下）
if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)